﻿using System;
using System.Collections.Generic;
using DeHeng_Mes.Constant;
using S7.Net;
using System.Management;
using DeHeng_Mes.Model;
using DeHeng_Mes.Model.Table;
using DeHeng_Mes.Model.PlcModel.door_01;
using DeHeng_Mes.Model.PlcModel.door_02;
using DeHeng_Mes.Model.PlcModel.door_03;
using DeHeng_Mes.Model.PlcModel.door_04;
using System.Windows.Input;
using System.Linq;

namespace DeHeng_Mes.Utils
{
    public static class MappingTable
    {
        /// <summary>
        /// plc数据与实体类的映射
        /// </summary>
        /// <param name="plc"></param>
        /// <param name="plcName"></param>
        /// <returns></returns>
        public static Dictionary<object, Type> PlcMapping(Plc plc, string plcName)
        {
            // 初始化返回值
            Dictionary<object, Type> dic = new Dictionary<object, Type>();

            // 定义一个类型和地址的映射表
            var typeAddressMap = new Dictionary<string, List<(Type type, int address)>>
            {
                { "DOOR-01", new List<(Type, int)>
                    {
                        (typeof(DoorPower01), 6002),
                        (typeof(DoorCode01), 5060),
                        (typeof(ErrorStatus01), 5110),
                        (typeof(QRResult01), 6004),
                         (typeof(DoorCheck01), 5061),
                    }
                },
                { "DOOR-02", new List<(Type, int)>
                    {
                        (typeof(DoorPower02), 6002),
                        (typeof(DoorProduction02), 6001),
                        (typeof(DoorCode02), 5060),
                        (typeof(ErrorStatus02), 5110),
                        (typeof(QRResult02), 6004),
                        (typeof(DoorCheck02), 5061),
                    }
                },
                { "DOOR-03", new List<(Type, int)>
                    {
                        (typeof(DoorCode03), 5060),
                        (typeof(ErrorStatus03), 5110),
                    }
                },
                { "DOOR-04", new List<(Type, int)>
                    {
                        (typeof(DoorCode04), 5060),
                        (typeof(ErrorStatus04), 5110),
                    }
                },
            };

            // 定义读取数据并添加到字典的方法
            void AddInstance(Type type, int address)
            {
                // 引用ReadClass方法的命名空间和类
                var method = typeof(Plc).GetMethod("ReadClass", new Type[] { typeof(int), typeof(int) })?.MakeGenericMethod(type);
                var instance = method.Invoke(plc, new object[] { address, 0 });
                dic.Add(instance, type);
            }

            try
            {
                // 检查并处理对应的Name类型
                if (typeAddressMap.ContainsKey(plcName))
                {
                    foreach (var (type, address) in typeAddressMap[plcName])
                    {
                        AddInstance(type, address);
                    }
                }

                return dic;
            }
            catch (Exception ex)
            {
                Tools.ProduceLogTextError($"{plcName}获取Plc数据实例与实例类型映射失败，原因是：" + ex.Message);
            }

            return dic;
        }

        /// <summary>
        /// 获取Cpu唯一标识
        /// </summary>
        public static string DeviceIdentifier()
        {
            string cpuId = string.Empty;
            using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("select ProcessorId from Win32_Processor"))
            {
                foreach (ManagementObject obj in searcher.Get())
                {
                    cpuId = obj["ProcessorId"].ToString();
                    break;
                }
            }
            return cpuId;
        }

        /// <summary>
        /// 设备与数据库账号映射表
        /// </summary>
        /// <param name="cpuIp"></param>
        /// <returns></returns>
        public static (string, string) GetSqlUser(string cpuIp)
        {
            string userName = "";
            string passWord = "";
            //BFEBFBFF000906EA
            //BFEBFBFF000906EA
            Dictionary<string, Dictionary<string, string>> dic = new Dictionary<string, Dictionary<string, string>>()
            {
                {"BFEBFBFF000906EA",new Dictionary<string, string>()
                {
                    { "sa","yk19991223"}
                } },
                {"BFEBFBFF000806EB",new Dictionary<string, string>()
                {
                    { "sa","GUANHAOmenchuang_0506"}
                } }
            };

            foreach (var item in dic)
            {
                if (item.Key.Equals(cpuIp))
                {
                    //解析Value
                    foreach (var item1 in item.Value)
                    {
                        userName = item1.Key;
                        passWord = item1.Value;
                    }
                }
            }
            userName = string.IsNullOrEmpty(userName) ? SystemConstant.MySqlName : userName;
            passWord = string.IsNullOrEmpty(passWord) ? SystemConstant.MySqlPassWord : passWord;
            return (userName, passWord);
        }

        /// <summary>
        /// 请求对照表
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public static string UrlAnalysis(string url)
        {
            Dictionary<string, string> dic
                = new Dictionary<string, string>()
                {
                    {"OrderInfo","ProcessRequest" },
                    {"ISVGlue","ISVGlue" },
                    {"receiveReport","receiveReport" },
                    {"HourProduction","HourProduction" },
                    {"StaticData","StaticData" },
                    {"DeviceFault","DeviceFault" },
                    {"NgWorkPart","NgWorkPart" },
                    {"OEE","OEE" },
                    {"NgPCT","NgPCT" },
                    {"HourPower","HourPower" },
                };
            foreach (var item in dic)
            {
                if (url.Contains(item.Key))
                {
                    return item.Value;
                }
            }
            return "";
        }

        /// <summary>
        /// 根据字符串判断是否是压铆工序
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static bool IsClinch(string key)
        {
            List<string> stations = new List<string>()
            {
                SystemConstant.OP10L,
                SystemConstant.OP10R,
            };

            if (!stations.Contains(key))
                return false;
            return true;
        }

        /// <summary>
        /// 获取该类字段与Plc数据映射
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Dictionary<string, Tuple<int, int>> GetDicByName(string key)
        {
            var dic = new Dictionary<string, Dictionary<string, Tuple<int, int>>>();

            #region 状态读取映射
            dic["DOOR-01-STATUS"] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.OP15L,new Tuple<int, int>(10,1)},
                { SystemConstant.OP20L,new Tuple<int, int>(1,1)},
                { SystemConstant.OP30L,new Tuple<int, int>(2,1)},
                { SystemConstant.OP40L,new Tuple<int, int>(3,1)},
                { SystemConstant.OP50L,new Tuple<int, int>(4,1)},
                { SystemConstant.OP60L,new Tuple<int, int>(5,1)},
                { SystemConstant.OP70L,new Tuple<int, int>(6,1)},
                { SystemConstant.OP80L,new Tuple<int, int>(7,1)},
                { SystemConstant.OP90L,new Tuple<int, int>(8,1)},
                { SystemConstant.OP100L,new Tuple<int, int>(9,1)},
                {"Op60L_NG",new Tuple<int, int>(11,1)},
                { "Op80L_NG",new Tuple<int, int>(12,1)},

                { SystemConstant.OP15R,new Tuple<int, int>(32,1)},
                { SystemConstant.OP20R,new Tuple<int, int>(23,1)},
                { SystemConstant.OP30R,new Tuple<int, int>(24,1)},
                { SystemConstant.OP40R,new Tuple<int, int>(25,1)},
                { SystemConstant.OP50R,new Tuple<int, int>(26,1)},
                { SystemConstant.OP60R,new Tuple<int, int>(27,1)},
                { SystemConstant.OP70R,new Tuple<int, int>(28,1)},
                { SystemConstant.OP80R,new Tuple<int, int>(29,1)},
                { SystemConstant.OP90R,new Tuple<int, int>(30,1)},
                { SystemConstant.OP100R,new Tuple<int, int>(31,1)},
                { "Op60R_NG",new Tuple<int, int>(33,1)},
                { "Op80R_NG",new Tuple<int, int>(34,1)},
            };

            dic["DOOR-02-STATUS"] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.OP110L,new Tuple<int, int>(10,1)},
                { SystemConstant.OP120L_A,new Tuple<int, int>(11,1)},
                { SystemConstant.OP120L_B,new Tuple<int, int>(9,1)},
                { SystemConstant.OP125L,new Tuple<int, int>(8,1)},
                { SystemConstant.OP130L,new Tuple<int, int>(12,1)},
                { SystemConstant.OP140L,new Tuple<int, int>(13,1)},
                { SystemConstant.OP150L,new Tuple<int, int>(14,1)},
                { SystemConstant.OP160L_1,new Tuple<int, int>(16,1)},
                { SystemConstant.OP160L_2,new Tuple<int, int>(17,1)},
                { SystemConstant.OP170L,new Tuple<int, int>(18,1)},
                { SystemConstant.OP180L,new Tuple<int, int>(19,1)},
                { "Op110L_NG",new Tuple<int, int>(7,1)},

                { SystemConstant.OP110R,new Tuple<int, int>(32,1)},
                { SystemConstant.OP120R_A,new Tuple<int, int>(33,1)},
                { SystemConstant.OP120R_B,new Tuple<int, int>(31,1)},
                { SystemConstant.OP125R,new Tuple<int, int>(30,1)},
                { SystemConstant.OP130R,new Tuple<int, int>(34,1)},
                { SystemConstant.OP140R,new Tuple<int, int>(35,1)},
                { SystemConstant.OP150R,new Tuple<int, int>(36,1)},
                { SystemConstant.OP160R_1,new Tuple<int, int>(38,1)},
                { SystemConstant.OP160R_2,new Tuple<int, int>(39,1)},
                { SystemConstant.OP170R,new Tuple<int, int>(40,1)},
                { SystemConstant.OP180R,new Tuple<int, int>(41,1)},
                { "Op110R_NG",new Tuple<int, int>(29,1)},
                { "Op155R_NG",new Tuple<int, int>(28,1)},
            };

            dic["DOOR-03-STATUS"] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.OP10L,new Tuple<int, int>(22,1)},
            };

            dic["DOOR-04-STATUS"] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.OP10R,new Tuple<int, int>(0,1)},
            };
            #endregion

            #region 左侧工位数据读取映射
            dic[SystemConstant.OP10L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(266,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(278,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(290,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(302,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(314,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(392,12)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(404,12)},
                { SystemConstant.BEAT,new Tuple<int, int>(428,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(430,1)},
            };

            dic[SystemConstant.OP10R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(126,12)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(138,12)},
                { SystemConstant.BEAT,new Tuple<int, int>(162,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(164,1)},
            };

            dic[SystemConstant.OP15L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1300,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1312,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1324,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1336,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1348,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1402,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1410,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1426,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1428,1)},
            };

            dic[SystemConstant.OP15R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1430,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1442,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1454,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1466,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1478,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1532,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1540,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1556,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1558,1)},
            };

            dic[SystemConstant.OP20L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP20R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(130,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(142,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(154,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(166,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(178,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(232,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(240,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(256,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(258,1)},
            };

            dic[SystemConstant.OP30L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(260,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(272,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(284,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(296,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(308,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(362,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(370,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(386,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(388,1)},
            };

            dic[SystemConstant.OP30R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(390,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(402,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(414,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(426,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(438,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(492,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(500,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(516,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(518,1)},
            };

            dic[SystemConstant.OP40L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(520,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(532,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(544,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(556,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(568,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(622,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(630,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(646,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(648,1)},
            };

            dic[SystemConstant.OP40R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(650,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(662,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(674,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(686,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(698,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(752,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(760,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(776,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(778,1)},
            };

            dic[SystemConstant.OP50L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(780,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(792,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(804,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(816,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(828,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(882,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(890,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(906,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(908,1)},
            };

            dic[SystemConstant.OP50R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(910,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(922,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(934,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(946,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(958,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1012,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1020,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1036,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1038,1)},
            };

            dic[SystemConstant.OP60L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP60R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(878,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(890,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(902,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(914,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(926,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(980,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(988,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1004,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1006,1)},
            };

            dic[SystemConstant.OP70L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP70R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(130,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(142,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(154,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(166,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(178,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(232,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(240,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(256,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(258,1)},
            };

            dic[SystemConstant.OP80L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1756,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1768,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1780,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1792,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1804,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1858,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1866,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1882,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1884,1)},
            };

            dic[SystemConstant.OP80R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(2124,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(2136,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(2148,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(2160,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(2172,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(2226,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(2234,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(2250,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(2252,1)},
            };

            dic[SystemConstant.OP90L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP90R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(260,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(272,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(284,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(296,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(308,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(362,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(370,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(386,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(388,1)},
            };

            dic[SystemConstant.OP100L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1040,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1052,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1064,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1076,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1088,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1142,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1150,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1166,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1168,1)},
            };

            dic[SystemConstant.OP100R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1170,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1182,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1194,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1206,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1218,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1272,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1280,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1296,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1298,1)},
            };


            #endregion

            #region 右侧工位数据读取映射
            dic[SystemConstant.OP110L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP110R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(538,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(550,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(562,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(574,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(586,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(640,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(648,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(664,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(666,1)},
            };

            dic[SystemConstant.OP120L_A] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP120L_B] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1040,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1052,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1064,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1076,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1088,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1142,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1150,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1166,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1168,1)},
            };

            dic[SystemConstant.OP120R_A] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(130,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(142,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(154,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(166,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(178,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(232,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(240,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(256,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(258,1)},
            };

            dic[SystemConstant.OP120R_B] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1170,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1182,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1194,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1206,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1218,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1272,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1280,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1296,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1298,1)},
            };

            dic[SystemConstant.OP125L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP125R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.RESULT,new Tuple<int, int>(268,1)},
            };

            dic[SystemConstant.OP130L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(260,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(272,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(284,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(296,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(308,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(362,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(370,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(386,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(388,1)},
            };

            dic[SystemConstant.OP130R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(390,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(402,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(414,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(426,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(438,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(492,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(500,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(516,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(518,1)},
            };

            dic[SystemConstant.OP140L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(520,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(532,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(544,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(556,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(568,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(622,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(630,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(646,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(648,1)},
            };

            dic[SystemConstant.OP140R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(650,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(662,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(674,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(686,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(698,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(752,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(760,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(776,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(778,1)},
            };

            dic[SystemConstant.OP150L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(780,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(792,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(804,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(816,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(828,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(882,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(890,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(906,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(908,1)},
            };

            dic[SystemConstant.OP150R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(910,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(922,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(934,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(946,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(958,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1012,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1020,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1036,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1038,1)},
            };

            dic[SystemConstant.OP160L_1] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1076,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1088,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1100,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1112,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1124,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1178,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1186,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1202,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1204,1)},
            };

            dic[SystemConstant.OP160L_2] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP160R_1] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(1342,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(1354,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(1366,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(1378,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(1390,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(1444,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(1452,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(1468,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(1470,1)},
            };

            dic[SystemConstant.OP160R_2] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(130,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(142,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(154,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(166,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(178,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(232,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(240,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(256,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(258,1)},
            };

            dic[SystemConstant.OP170L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP170R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(202,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(214,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(226,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(238,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(250,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(304,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(312,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(328,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(330,1)},
            };

            dic[SystemConstant.OP180L] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(0,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(12,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(24,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(36,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(48,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(102,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(110,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(126,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(128,1)},
            };

            dic[SystemConstant.OP180R] = new Dictionary<string, Tuple<int, int>>()
            {
                { SystemConstant.STATION,new Tuple<int, int>(130,10)},
                { SystemConstant.BATCH,new Tuple<int, int>(142,10)},
                { SystemConstant.TYPE,new Tuple<int, int>(154,10)},
                { SystemConstant.WORKER,new Tuple<int, int>(166,10)},
                { SystemConstant.RBNO,new Tuple<int, int>(178,10)},
                { SystemConstant.STARTTIME,new Tuple<int, int>(232,8)},
                { SystemConstant.ENDTIME,new Tuple<int, int>(240,8)},
                { SystemConstant.BEAT,new Tuple<int, int>(256,2)},
                { SystemConstant.RESULT,new Tuple<int, int>(258,1)},
            };
            #endregion

            #region 工艺数据读取映射
            #endregion




            // 返回匹配数据
            if (dic.TryGetValue(key, out Dictionary<string, Tuple<int, int>> data))
                return data;

            return null;
        }

        /// <summary>
        /// 获取已读数据
        /// </summary>
        /// <param name="stationStatus"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public static Tuple<int, int> GetReturnBytesOff(string stationStatus)
        {
            var dic = new Dictionary<string, Tuple<int, int>>();
            #region 状态读取数组
            dic["DOOR-01-STATUS"] = new Tuple<int, int>(5001, 87);
            dic["DOOR-02-STATUS"] = new Tuple<int, int>(5001, 87);
            dic["DOOR-03-STATUS"] = new Tuple<int, int>(5001, 87);
            dic["DOOR-04-STATUS"] = new Tuple<int, int>(5001, 87);
            #endregion

            if (dic.TryGetValue(stationStatus, out Tuple<int, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 根据字符串数据获取相关DB数据的二元组
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static Tuple<int, int> GetBytesOff(string key)
        {
            var dic = new Dictionary<string, Tuple<int, int>>();
            #region 状态读取数组
            dic["DOOR-01-STATUS"] = new Tuple<int, int>(SystemConstant.PLC01_STATUS_DB, SystemConstant.PLC01_STATUS_ENDOFF);
            dic["DOOR-02-STATUS"] = new Tuple<int, int>(SystemConstant.PLC02_STATUS_DB, SystemConstant.PLC02_STATUS_ENDOFF);
            dic["DOOR-03-STATUS"] = new Tuple<int, int>(SystemConstant.PLC03_STATUS_DB, SystemConstant.PLC03_STATUS_ENDOFF);
            dic["DOOR-04-STATUS"] = new Tuple<int, int>(SystemConstant.PLC04_STATUS_DB, SystemConstant.PLC04_STATUS_ENDOFF);
            #endregion

            #region PLC01数据数组
            dic["DOOR-01-FDS"] = new Tuple<int, int>(SystemConstant.PLC01_FDS_DB, SystemConstant.PLC01_FDS_ENDOFF);
            dic["DOOR-01-TIGHTEN"] = new Tuple<int, int>(SystemConstant.PLC01_TIGHTEN_DB, SystemConstant.PLC01_TIGHTEN_ENDOFF);
            dic["DOOR-01-RIVRTE"] = new Tuple<int, int>(SystemConstant.PLC01_RIVETE_DB, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic["DOOR-01-GLUE"] = new Tuple<int, int>(SystemConstant.PLC01_GLUE_DB, SystemConstant.PLC01_GLUE_ENDOFF);
            #endregion

            #region PLC02数据数组
            dic["DOOR-02-FDS"] = new Tuple<int, int>(SystemConstant.PLC02_FDS_DB, SystemConstant.PLC02_FDS_ENDOFF);
            dic["DOOR-02-TIGHTEN"] = new Tuple<int, int>(SystemConstant.PLC02_TIGHTEN_DB, SystemConstant.PLC02_TIGHTEN_ENDOFF);
            dic["DOOR-02-RIVRTE"] = new Tuple<int, int>(SystemConstant.PLC02_RIVETE_DB, SystemConstant.PLC02_RIVETE_ENDOFF);
            dic["DOOR-02-GLUE"] = new Tuple<int, int>(SystemConstant.PLC02_GLUE_DB, SystemConstant.PLC02_GLUE_ENDOFF);
            dic["DOOR-02-WELD"] = new Tuple<int, int>(SystemConstant.PLC02_WELD_DB, SystemConstant.PLC02_WELD_ENDOFF);
            dic["DOOR-02-POINT"] = new Tuple<int, int>(SystemConstant.PLC02_POINT_DB, SystemConstant.PLC02_POINT_ENDOFF);
            dic["DOOR-02-CCD"] = new Tuple<int, int>(SystemConstant.PLC02_CCD1_DB, SystemConstant.PLC02_CCD1_ENDOFF);
            #endregion

            #region PLC03数据数组
            dic["DOOR-03-CLINCH"] = new Tuple<int, int>(5040, 532);
            #endregion

            #region PLC04数据数组
            dic["DOOR-04-CLINCH"] = new Tuple<int, int>(5040, 532);
            #endregion

            if (dic.TryGetValue(key, out Tuple<int, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 获取工位数组偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Tuple<int, int> GetStationOff(string station)
        {
            Dictionary<string, Tuple<int, int>> dic = new Dictionary<string, Tuple<int, int>>();

            dic[SystemConstant.OP10L] = new Tuple<int, int>(5040, 532);
            dic[SystemConstant.OP15L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP20L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP30L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP40L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP50L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP60L] = new Tuple<int, int>(5010, SystemConstant.PLC01_GLUE_ENDOFF);
            dic[SystemConstant.OP70L] = new Tuple<int, int>(5020, SystemConstant.PLC01_FDS_ENDOFF);
            dic[SystemConstant.OP80L] = new Tuple<int, int>(5010, SystemConstant.PLC01_GLUE_ENDOFF);
            dic[SystemConstant.OP90L] = new Tuple<int, int>(5030, SystemConstant.PLC01_TIGHTEN_ENDOFF);
            dic[SystemConstant.OP100L] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP110L] = new Tuple<int, int>(5010, SystemConstant.PLC02_GLUE_ENDOFF);
            dic[SystemConstant.OP120L_A] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP120L_B] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP125L] = new Tuple<int, int>(5022, SystemConstant.PLC02_CCD1_ENDOFF);
            dic[SystemConstant.OP130L] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP140L] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP150L] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP160L_1] = new Tuple<int, int>(5010, SystemConstant.PLC02_GLUE_ENDOFF);
            dic[SystemConstant.OP160L_2] = new Tuple<int, int>(5040, SystemConstant.PLC02_TIGHTEN_ENDOFF);
            dic[SystemConstant.OP170L] = new Tuple<int, int>(5030, SystemConstant.PLC02_WELD_ENDOFF);
            dic[SystemConstant.OP180L] = new Tuple<int, int>(5080, SystemConstant.PLC02_CCD2_ENDOFF);

            dic[SystemConstant.OP10R] = new Tuple<int, int>(5040, 532);
            dic[SystemConstant.OP15R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP20R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP30R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP40R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP50R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP60R] = new Tuple<int, int>(5010, SystemConstant.PLC01_GLUE_ENDOFF);
            dic[SystemConstant.OP70R] = new Tuple<int, int>(5020, SystemConstant.PLC01_FDS_ENDOFF);
            dic[SystemConstant.OP80R] = new Tuple<int, int>(5010, SystemConstant.PLC01_GLUE_ENDOFF);
            dic[SystemConstant.OP90R] = new Tuple<int, int>(5030, SystemConstant.PLC01_TIGHTEN_ENDOFF);
            dic[SystemConstant.OP100R] = new Tuple<int, int>(5050, SystemConstant.PLC01_RIVETE_ENDOFF);
            dic[SystemConstant.OP110R] = new Tuple<int, int>(5010, SystemConstant.PLC02_GLUE_ENDOFF);
            dic[SystemConstant.OP120R_A] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP120R_B] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP125R] = new Tuple<int, int>(5022, SystemConstant.PLC02_CCD1_ENDOFF);
            dic[SystemConstant.OP130R] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP140R] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP150R] = new Tuple<int, int>(5020, SystemConstant.PLC02_FDS_ENDOFF);
            dic[SystemConstant.OP160R_1] = new Tuple<int, int>(5010, SystemConstant.PLC02_GLUE_ENDOFF);
            dic[SystemConstant.OP160R_2] = new Tuple<int, int>(5040, SystemConstant.PLC02_TIGHTEN_ENDOFF);
            dic[SystemConstant.OP170R] = new Tuple<int, int>(5030, SystemConstant.PLC02_WELD_ENDOFF);
            dic[SystemConstant.OP180R] = new Tuple<int, int>(5080, SystemConstant.PLC02_CCD2_ENDOFF);

            if (dic.TryGetValue(station, out Tuple<int, int> value))
            {
                return value;
            }

            return null;
        }

        /// <summary>
        /// 根据PlcName与StationName获取工艺名称
        /// </summary>
        /// <param name="plcName"></param>
        /// <param name="StationName"></param>
        /// <returns></returns>
        public static string GetOperationNo(string plcName, string StationName)
        {
            var dic = new Dictionary<string, Dictionary<string, string>>();

            dic["DOOR-01"] = new Dictionary<string, string>
            {
                { "Op60L","GLUE"},
                { "Op60R","GLUE"},
                { "Op80L","GLUE"},
                { "Op80R","GLUE"},
            };

            dic["DOOR-02"] = new Dictionary<string, string>
            {
                { "Op110L","GLUE"},
                { "Op110R","GLUE"},
                { "Op125L","CCD"},
                { "Op125R","CCD"},
                { "Op160L_1","GLUE"},
                { "Op160R_1","GLUE"},
                { "Op160L_2","POINT"},
                { "Op160R_2","POINT"},
                { "Op170L","WELD"},
                { "Op170R","WELD"},
            };

            dic["DOOR-03"] = new Dictionary<string, string>
            {
                { "Op10L","CLINCH"},
                { "Op10R","CLINCH"},
            };

            dic["DOOR-04"] = new Dictionary<string, string>
            {
                { "Op10L","CLINCH"},
                { "Op10R","CLINCH"},
            };

            if (dic.TryGetValue(plcName, out Dictionary<string, string> operationDic))
            {
                if (operationDic.TryGetValue(StationName, out string value))
                    return value;
            }
            return null;
        }

        /// <summary>
        /// 根据工位获取对应工序号
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static string GetOperationId(string station)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                { SystemConstant.OP10L,"A075"}, // 压铆1
                { SystemConstant.OP15L,"A146"}, // 抽芯拉铆1
                { SystemConstant.OP20L,"A228"}, // 抽芯拉铆2
                { SystemConstant.OP30L,"A229"}, // 抽芯拉铆3
                { SystemConstant.OP40L,"A230"}, // 抽芯拉铆4
                { SystemConstant.OP50L,"A231"}, // 抽芯拉铆5
                { SystemConstant.OP60L,"A242"}, // 涂胶2
                { SystemConstant.OP70L,"A080"}, // fds1
                { SystemConstant.OP80L,"A243"}, // 涂胶3
                { SystemConstant.OP90L,"A232,Q"}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP100L,"A233"}, // 抽芯拉铆7
                { SystemConstant.OP110L,"A249"}, // 涂胶4
                { SystemConstant.OP120L_A,"A188"}, // fds2 抽芯拉铆8
                { SystemConstant.OP120L_B,"A188"}, // fds2 抽芯拉铆8
                { SystemConstant.OP125L,"A059"}, // ccd1
                { SystemConstant.OP130L,"A223"}, // fds3
                { SystemConstant.OP140L,"A224"}, // fds4
                { SystemConstant.OP150L,"A225"}, // fds5
                { SystemConstant.OP160L_1,"A250"}, // 涂胶5
                { SystemConstant.OP160L_2,"A163"}, // 拧紧 打刻
                { SystemConstant.OP170L,"A279"}, // 点焊
                { SystemConstant.OP180L,"A282"}, // ccd2

                { SystemConstant.OP10R,"A075"}, // 压铆1
                { SystemConstant.OP15R,"A146"}, // 抽芯拉铆1
                { SystemConstant.OP20R,"A228"}, // 抽芯拉铆2
                { SystemConstant.OP30R,"A229"}, // 抽芯拉铆3
                { SystemConstant.OP40R,"A230"}, // 抽芯拉铆4
                { SystemConstant.OP50R,"A231"}, // 抽芯拉铆5
                { SystemConstant.OP60R,"A242"}, // 涂胶2
                { SystemConstant.OP70R,"A080"}, // fds1
                { SystemConstant.OP80R,"A243"}, // 涂胶3
                { SystemConstant.OP90R,"A163,Q"}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP100R,"A232"}, // 抽芯拉铆7
                { SystemConstant.OP110R,"A249"}, // 涂胶4
                { SystemConstant.OP120R_A,"A188"}, // fds2 抽芯拉铆8
                { SystemConstant.OP120R_B,"A188"}, // fds2 抽芯拉铆8
                { SystemConstant.OP125R,"A059"}, // ccd1
                { SystemConstant.OP130R,"A223"}, // fds3
                { SystemConstant.OP140R,"A224"}, // fds4
                { SystemConstant.OP150R,"A225"}, // fds5
                { SystemConstant.OP160R_1,"A250"}, // 涂胶5
                { SystemConstant.OP160R_2,"A164"}, // 拧紧 打刻
                { SystemConstant.OP170R,"A279"}, // 点焊
                { SystemConstant.OP180R,"A282"}, // ccd2
            };

            if (dic.TryGetValue(station,out string value))
            {
                return value;
            }

            return "未映射";
        }

        public static List<int> GetResultOff(string plcName, string station)
        {
            string operationId = GetOperationId(station);

            List<string> list = operationId.Split(',').ToList();

            List<int> result = new List<int>();

            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic["DOOR-01"] = new Dictionary<string, int>
            {
                { SystemConstant.OP15L + "A146", 0}, // 抽芯拉铆1
                { SystemConstant.OP20L + "A228", 1}, // 抽芯拉铆2
                { SystemConstant.OP30L + "A229", 2}, // 抽芯拉铆3
                { SystemConstant.OP40L + "A230", 3}, // 抽芯拉铆4
                { SystemConstant.OP50L + "A231", 4}, // 抽芯拉铆5
                { SystemConstant.OP60L + "A242", 5}, // 涂胶2
                { SystemConstant.OP70L + "A080", 6}, // fds1
                { SystemConstant.OP80L + "A243", 7}, // 涂胶3
                { SystemConstant.OP90L + "Q", 8}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP90L + "A232", 9}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP100L + "A233", 10}, // 抽芯拉铆7

                { SystemConstant.OP15R + "A146", 16}, // 抽芯拉铆1
                { SystemConstant.OP20R + "A228", 17}, // 抽芯拉铆2
                { SystemConstant.OP30R + "A229", 18}, // 抽芯拉铆3
                { SystemConstant.OP40R + "A230", 19}, // 抽芯拉铆4
                { SystemConstant.OP50R + "A231", 20}, // 抽芯拉铆5
                { SystemConstant.OP60R + "A242", 21}, // 涂胶2
                { SystemConstant.OP70R + "A080", 22}, // fds1
                { SystemConstant.OP80R + "A243", 23}, // 涂胶3
                { SystemConstant.OP90R + "Q", 24}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP90R + "A163", 25}, // 螺接1 抽芯拉铆6
                { SystemConstant.OP100R + "A232", 26}, // 抽芯拉铆7
            };

            dic["DOOR-02"] = new Dictionary<string, int>
            {
                { SystemConstant.OP110L + "A249", 0}, // 涂胶4
                { SystemConstant.OP120L_A + "A188", 2}, // fds2 抽芯拉铆8
                { SystemConstant.OP120L_B + "A188", 4}, // fds2 抽芯拉铆8
                { SystemConstant.OP125L + "A059", 5}, // ccd1
                { SystemConstant.OP130L + "A223", 6}, // fds3
                { SystemConstant.OP140L + "A224", 7}, // fds4
                { SystemConstant.OP150L + "A225", 8}, // fds5
                { SystemConstant.OP160L_1 + "A250", 9}, // 涂胶5
                { SystemConstant.OP160L_2 + "A163", 10}, // 拧紧 打刻
                { SystemConstant.OP170L + "A279", 12}, // 点焊
                { SystemConstant.OP180L + "A282", 13}, // ccd2

                { SystemConstant.OP110R + "A249", 20}, // 涂胶4
                { SystemConstant.OP120R_A + "A188", 22}, // fds2 抽芯拉铆8
                { SystemConstant.OP120R_B + "A188", 24}, // fds2 抽芯拉铆8
                { SystemConstant.OP125R + "A059", 25}, // ccd1
                { SystemConstant.OP130R + "A223", 26}, // fds3
                { SystemConstant.OP140R + "A224", 27}, // fds4
                { SystemConstant.OP150R + "A225", 28}, // fds5
                { SystemConstant.OP160R_1 + "A250", 29}, // 涂胶5
                { SystemConstant.OP160R_2 + "A164", 30}, // 拧紧 打刻
                { SystemConstant.OP170R + "A279", 32}, // 点焊
                { SystemConstant.OP180R + "A282", 33}, // ccd2
            };

            dic["DOOR-03"] = new Dictionary<string, int>
            {
                { SystemConstant.OP10L + "A075", 430}, // 压铆1
            };

            dic["DOOR-04"] = new Dictionary<string, int>
            {
                { SystemConstant.OP10R + "A075", 164}, // 压铆1
            };

            foreach (string operation in list)
            {
                string key = station + operation;

                if (dic.TryGetValue(plcName, out Dictionary<string, int> value))
                {
                    if (value.TryGetValue(key, out int off))
                        result.Add(off);
                }
            }

            return result;
        }

        /// <summary>
        /// 获取CCD偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetCCDOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic["Op125L"] = new Dictionary<string, int>()
            {
                {"Off", 6},
                {"Number", 130},
                {"Result", 162},
            };

            dic["Op125R"] = new Dictionary<string, int>()
            {
                {"Off", 6},
                {"Number", 464},
                {"Result", 496},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
            {
                return value;
            }
            return null;
        }

        /// <summary>
        /// 获取涂胶数据偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetGlueOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic["Op60L"] = new Dictionary<string, int>()
            {
                {"Off", 19},
                {"RangeNo", 130},
                {"StartTime", 132},
                {"EndTime", 140},
                {"Press", 148},
                {"Speed", 152},
                {"Amount", 156},
                {"Temperature", 160},
            };

            dic["Op60R"] = new Dictionary<string, int>()
            {
                {"Off", 18},
                {"RangeNo", 1008},
                {"StartTime", 1010},
                {"EndTime", 1018},
                {"Press", 1026},
                {"Speed", 1030},
                {"Amount", 1034},
                {"Temperature", 1038},
            };

            dic["Op80L"] = new Dictionary<string, int>()
            {
                {"Off", 5},
                {"RangeNo", 1886},
                {"StartTime", 1888},
                {"EndTime", 1896},
                {"Press", 1904},
                {"Speed", 1908},
                {"Amount", 1912},
                {"Temperature", 1916},
            };

            dic["Op80R"] = new Dictionary<string, int>()
            {
                {"Off", 5},
                {"RangeNo", 2254},
                {"StartTime", 2256},
                {"EndTime", 2264},
                {"Press", 2272},
                {"Speed", 2276},
                {"Amount", 2280},
                {"Temperature", 2284},
            };

            dic["Op110L"] = new Dictionary<string, int>()
            {
                {"Off", 7},
                {"RangeNo", 130},
                {"StartTime", 132},
                {"EndTime", 140},
                {"Press", 148},
                {"Speed", 152},
                {"Amount", 156},
                {"Temperature", 160},
            };

            dic["Op110R"] = new Dictionary<string, int>()
            {
                {"Off", 7},
                {"RangeNo", 668},
                {"StartTime", 670},
                {"EndTime", 678},
                {"Press", 686},
                {"Speed", 690},
                {"Amount", 694},
                {"Temperature", 698},
            };

            dic["Op160L_1"] = new Dictionary<string, int>()
            {
                {"Off", 2},
                {"RangeNo", 1206},
                {"StartTime", 1208},
                {"EndTime", 1216},
                {"Press", 1224},
                {"Speed", 1228},
                {"Amount", 1232},
                {"Temperature", 1236},
            };

            dic["Op160R_1"] = new Dictionary<string, int>()
            {
                {"Off", 2},
                {"RangeNo", 1472},
                {"StartTime", 1474},
                {"EndTime", 1482},
                {"Press", 1490},
                {"Speed", 1494},
                {"Amount", 1498},
                {"Temperature", 1502},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
            {
                return value;
            }
            return null;
        }

        /// <summary>
        /// 获取弧焊数据偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static Dictionary<string, int> GetWeldOff(string station)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic["Op170L"] = new Dictionary<string, int>()
            {
                {"Off", 4},
                {"ErrorCode", 130},
                {"Num", 131},
                {"ReHotTime", 132},
                {"ReHotA", 134},
                {"ReHotV", 136},
                {"WeldTime", 138},
                {"WeldA", 140},
                {"WeldV", 142},
                {"R", 144},
                {"StatusNo", 146},
                {"Result", 147},
            };

            dic["Op170R"] = new Dictionary<string, int>()
            {
                {"Off", 4},
                {"ErrorCode", 332},
                {"Num", 333},
                {"ReHotTime", 334},
                {"ReHotA", 336},
                {"ReHotV", 338},
                {"WeldTime", 340},
                {"WeldA", 342},
                {"WeldV", 344},
                {"R", 346},
                {"StatusNo", 348},
                {"Result", 349},
            };

            if (dic.TryGetValue(station, out Dictionary<string, int> value))
            {
                return value;
            }
            return null;
        }

        /// <summary>
        /// 获取放重数据数据
        /// </summary>
        /// <param name="plcName"></param>
        /// <returns></returns>
        public static Tuple<int, int> GetErrorOffByte(string plcName)
        {
            Dictionary<string, Tuple<int, int>> dic = new Dictionary<string, Tuple<int, int>>();

            dic["DOOR-01"] = new Tuple<int, int>(0, 1);

            if (dic.TryGetValue(plcName, out Tuple<int, int> value))
                return value;
            return null;
        }

        /// <summary>
        /// 返回偏移量
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static int GetPutErrorOff(string station)
        {
            Dictionary<string, int> keyValuePairs = new Dictionary<string, int>()
            {
                { "Op20L",45},
                { "Op30L",46},
                { "Op40L",47},
                { "Op50L",48},
                { "Op15L",54},

                { "Op20R",67},
                { "Op30R",68},
                { "Op40R",69},
                { "Op50R",70},
                { "Op15R",76},
            };

            if (keyValuePairs.TryGetValue(station, out int value))
                return value;
            return 100;
        }

        /// <summary>
        /// 根据工站获取已读信号
        /// </summary>
        /// <param name="station"></param>
        public static int GetReadOff(string station)
        {
            Dictionary<string, int> keyValuePairs = new Dictionary<string, int>()
            {
                { "Op10L",22},
                { "Op15L",10},
                { "Op20L",1},
                { "Op30L",2},
                { "Op40L",3},
                { "Op50L",4},
                { "Op60L",5},
                { "Op70L",6},
                { "Op80L",7},
                { "Op90L",8},
                { "Op100L",9},
                { "Op60L_NG",11},
                { "Op80L_NG",12},

                { "Op10R",0},
                { "Op15R",32},
                { "Op20R",23},
                { "Op30R",24},
                { "Op40R",25},
                { "Op50R",26},
                { "Op60R",27},
                { "Op70R",28},
                { "Op80R",29},
                { "Op90R",30},
                { "Op100R",31},
                { "Op60R_NG",33},
                { "Op80R_NG",34},


                { "Op110L",10},
                { "Op120L_A",11},
                { "Op120L_B",9},
                { "Op125L",8},
                { "Op130L",12},
                { "Op140L",13},
                { "Op150L",14},
                { "Op160L_1",16},
                { "Op160L_2",17},
                { "Op170L",18},
                { "Op180L",19},
                { "Op110L_NG",7},

                { "Op110R",32},
                { "Op120R_A",33},
                { "Op120R_B",31},
                { "Op125R",30},
                { "Op130R",34},
                { "Op140R",35},
                { "Op150R",36},
                { "Op160R_1",38},
                { "Op160R_2",39},
                { "Op170R",40},
                { "Op180R",41},
                { "Op155R_NG",28},
                { "Op110R_NG",29},
            };


            if (keyValuePairs.TryGetValue(station, out int value))
                return value;
            return 1000;
        }

        /// <summary>
        /// 获取上一个工位编号
        /// </summary>
        /// <param name="station"></param>
        /// <returns></returns>
        public static string GetLastStation(string station)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                { SystemConstant.OP15L,SystemConstant.OP10L},
                { SystemConstant.OP20L,SystemConstant.OP15L},
                { SystemConstant.OP30L,SystemConstant.OP20L},
                { SystemConstant.OP40L,SystemConstant.OP30L},
                { SystemConstant.OP50L,SystemConstant.OP40L},
                { SystemConstant.OP60L,SystemConstant.OP50L},
                { SystemConstant.OP70L,SystemConstant.OP60L},
                { SystemConstant.OP80L,SystemConstant.OP70L},
                { SystemConstant.OP90L,SystemConstant.OP80L},
                { SystemConstant.OP100L,SystemConstant.OP90L},
                { SystemConstant.OP110L,SystemConstant.OP100L},
                { SystemConstant.OP120L_A,SystemConstant.OP110L},
                { SystemConstant.OP120L_B,SystemConstant.OP110L},
                { SystemConstant.OP125L,SystemConstant.OP120L_A + "," + SystemConstant.OP120L_B},
                { SystemConstant.OP130L,SystemConstant.OP125L},
                { SystemConstant.OP140L,SystemConstant.OP130L},
                { SystemConstant.OP150L,SystemConstant.OP140L},
                { SystemConstant.OP160L_1,SystemConstant.OP150L},
                { SystemConstant.OP160L_2,SystemConstant.OP160L_1},
                { SystemConstant.OP170L,SystemConstant.OP160L_2},
                { SystemConstant.OP180L,SystemConstant.OP170L},

                { SystemConstant.OP15R,SystemConstant.OP10R},
                { SystemConstant.OP20R,SystemConstant.OP15R},
                { SystemConstant.OP30R,SystemConstant.OP20R},
                { SystemConstant.OP40R,SystemConstant.OP30R},
                { SystemConstant.OP50R,SystemConstant.OP40R},
                { SystemConstant.OP60R,SystemConstant.OP50R},
                { SystemConstant.OP70R,SystemConstant.OP60R},
                { SystemConstant.OP80R,SystemConstant.OP70R},
                { SystemConstant.OP90R,SystemConstant.OP80R},
                { SystemConstant.OP100R,SystemConstant.OP90R},
                { SystemConstant.OP110R,SystemConstant.OP100R},
                { SystemConstant.OP120R_A,SystemConstant.OP110R},
                { SystemConstant.OP120R_B,SystemConstant.OP110R},
                { SystemConstant.OP125R,SystemConstant.OP120R_A + "," + SystemConstant.OP120R_B},
                { SystemConstant.OP130R,SystemConstant.OP125R},
                { SystemConstant.OP140R,SystemConstant.OP130R},
                { SystemConstant.OP150R,SystemConstant.OP140R},
                { SystemConstant.OP160R_1,SystemConstant.OP150R},
                { SystemConstant.OP160R_2,SystemConstant.OP160R_1},
                { SystemConstant.OP170R,SystemConstant.OP160R_2},
                { SystemConstant.OP180R,SystemConstant.OP170R},
            };

            if (dic.TryGetValue(station, out string value))
            {
                return value;
            }
            return "";
        }

        /// <summary>
        /// 判断该物料是否是该线体的产品
        /// </summary>
        /// <param name="material_id"></param>
        /// <returns></returns>
        public static bool IsExistLine(string material_id)
        {
            /*List<string> lines = new List<string>()
            {
                ,
            };

            if (!string.IsNullOrWhiteSpace(material_id) && lines.Contains(material_id))
                return true;
            return false;*/

            return true;
        }

        /// <summary>
        /// 根据物料编码查找工单位置索引
        /// </summary>
        /// <param name="wo_code"></param>
        /// <returns></returns>
        public static int GetOrderIndex(string material_id)
        {
            Dictionary<string, int> dic = new Dictionary<string, int>()
            {
                { "100401002103",1},
                { "100401002102",2},
            };

            if (dic.TryGetValue(material_id, out int value))
            {
                return value;
            }

            return 0;
        }

        /// <summary>
        /// 根据plcName获取返回偏移量
        /// </summary>
        /// <param name="plcName"></param>
        /// <returns></returns>
        public static int GetPartResultOff(string plcName, string name)
        {
            Dictionary<string, Dictionary<string, int>> dic = new Dictionary<string, Dictionary<string, int>>();

            dic["DOOR-01"] = new Dictionary<string, int>
            {
                { "LCode1",1},
                { "LCode2",2},
                { "LCode3",3},
                { "LCode4",4},
                { "LCode5",5},
                { "LCode6",6},
                { "LCode7",7},
                { "LCode8",8},
                { "LCode9",9},
                { "LCode10",10},
                { "LCode11",11},
                { "LCode12",12},
                { "LCode13",13},
                { "LCode14",14},
                { "LCode15",15},
                { "LCode16",16},
                { "LCode17",17},
                { "LCode18",18},

                { "RCode1",19},
                { "RCode2",20},
                { "RCode3",21},
                { "RCode4",22},
                { "RCode5",23},
                { "RCode6",24},
                { "RCode7",25},
                { "RCode8",26},
                { "RCode9",27},
                { "RCode10",28},
                { "RCode11",29},
                { "RCode12",30},
                { "RCode13",31},
                { "RCode14",32},
                { "RCode15",33},
                { "RCode16",34},
                { "RCode17",35},
                { "RCode18",36},
            };

            dic["DOOR-02"] = new Dictionary<string, int>
            {
                { "LCode1",1},
                { "LCode2",2},
                { "LCode3",3},
                { "LCode4",4},
                { "LCode5",5},
                { "LCode6",6},
                { "LCode7",7},
                { "LCode8",8},
                { "LCode9",9},
                { "LCode10",10},
                { "LCode11",11},

                { "RCode1",12},
                { "RCode2",13},
                { "RCode3",14},
                { "RCode4",15},
                { "RCode5",16},
                { "RCode6",17},
                { "RCode7",18},
                { "RCode8",19},
                { "RCode9",20},
                { "RCode10",21},
                { "RCode11",22},
            };

            dic["DOOR-03"] = new Dictionary<string, int>
            {
                { "Code1",0},
            };

            dic["DOOR-04"] = new Dictionary<string, int>
            {
                { "Code1",0},
            };

            if (dic.TryGetValue(plcName,out Dictionary<string, int> value))
            {
                if (value.TryGetValue(name,out int off))
                    return off;
            }

            return 1000;
        }

        internal static string GetMaterialByStation(string station)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>()
            {
                { SystemConstant.OP10L,"100401002102"},
                { SystemConstant.OP15L,"100401002102"},
                { SystemConstant.OP20L,"100401002102"},
                { SystemConstant.OP30L,"100401002102"},
                { SystemConstant.OP40L,"100401002102"},
                { SystemConstant.OP50L,"100401002102"},
                { SystemConstant.OP60L,"100401002102"},
                { SystemConstant.OP70L,"100401002102"},
                { SystemConstant.OP80L,"100401002102"},
                { SystemConstant.OP90L,"100401002102"},
                { SystemConstant.OP100L,"100401002102"},
                { SystemConstant.OP110L,"100401002102"},
                { SystemConstant.OP120L_A,"100401002102"},
                { SystemConstant.OP120L_B,"100401002102"},
                { SystemConstant.OP125L,"100401002102"},
                { SystemConstant.OP130L,"100401002102"},
                { SystemConstant.OP140L,"100401002102"},
                { SystemConstant.OP150L,"100401002102"},
                { SystemConstant.OP160L_1,"100401002102"},
                { SystemConstant.OP160L_2,"100401002102"},
                { SystemConstant.OP170L,"100401002102"},
                { SystemConstant.OP180L,"100401002102"},

                { SystemConstant.OP10R,"100401002103"},
                { SystemConstant.OP15R,"100401002103"},
                { SystemConstant.OP20R,"100401002103"},
                { SystemConstant.OP30R,"100401002103"},
                { SystemConstant.OP40R,"100401002103"},
                { SystemConstant.OP50R,"100401002103"},
                { SystemConstant.OP60R,"100401002103"},
                { SystemConstant.OP70R,"100401002103"},
                { SystemConstant.OP80R,"100401002103"},
                { SystemConstant.OP90R,"100401002103"},
                { SystemConstant.OP100R,"100401002103"},
                { SystemConstant.OP110R,"100401002103"},
                { SystemConstant.OP120R_A,"100401002103"},
                { SystemConstant.OP120R_B,"100401002103"},
                { SystemConstant.OP125R,"100401002103"},
                { SystemConstant.OP130R,"100401002103"},
                { SystemConstant.OP140R,"100401002103"},
                { SystemConstant.OP150R,"100401002103"},
                { SystemConstant.OP160R_1,"100401002103"},
                { SystemConstant.OP160R_2,"100401002103"},
                { SystemConstant.OP170R,"100401002103"},
                { SystemConstant.OP180R,"100401002103"},
            };

            if (dic.TryGetValue(station, out string value))
                return value;

            return "";
        }

        /// <summary>
        /// 根据物料编码获取PlcName
        /// </summary>
        /// <param name="material_id"></param>
        /// <returns></returns>
        public static List<string> GetPlcNameByMaterial(string material_id)
        {
            Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>()
            {
                {"100401002102",new List<string>(){ "DOOR-01", "DOOR-02" , "DOOR-03" } },
                {"100401002103",new List<string>(){ "DOOR-01", "DOOR-02" , "DOOR-04" } },
            };

            if (dic.TryGetValue(material_id, out List<string> plcName))
            {
                return plcName;
            }

            return null;
        }
    }
}
